package com.sdp.lease.db.l_tenant_info.service.impl;

import com.sdp.lease.db.l_tenant_apply_info.entity.LTenantApplyInfo;
import com.sdp.lease.db.l_tenant_info.entity.LTenantInfo;
import com.sdp.lease.db.l_tenant_info.mapper.LTenantInfoMapper;
import com.sdp.lease.db.l_tenant_info.service.ILTenantInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsp
 * @since 2024-07-25
 */
@Service
public class LTenantInfoServiceImpl extends ServiceImpl<LTenantInfoMapper, LTenantInfo> implements ILTenantInfoService {

	@Override
	public LTenantInfo queryTenantInfoByAccountNo(String accountNo) {
		LambdaQueryWrapper<LTenantInfo> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(LTenantInfo::getTenantAccountNo, accountNo);
		return getOne(queryWrapper);
		
	}

	@Override
	public int queryTenantInfoIsExist(LTenantApplyInfo appInfo) {
		LambdaQueryWrapper<LTenantInfo> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(LTenantInfo::getTenantAccountNo, appInfo.getTenantAccountNo())
			.or().eq(LTenantInfo::getTenantCardCode, appInfo.getTenantCardCode())
			.or().eq(LTenantInfo::getTenantUscc, appInfo.getTenantUscc());
		return count(queryWrapper);
	}

}
